Skip to content

perf(vitest): halve spec suite time with node specs and worker threads - #1377

Open
askov wants to merge 3 commits into
solana-foundation:masterfrom
hoodieshq:chore/vitest-environments
Open

askov wants to merge 3 commits into
solana-foundation:masterfrom
hoodieshq:chore/vitest-environments

Conversation

@askov

@askov askov commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Description

A .ts spec runs in node instead of jsdom, and each spec file runs in a worker thread. The spec suite takes about half the time.

Speed

Before After Change
Local vitest run 1m15s 37s −51%
CI Test specs, slowest shard 2m50s 1m25s −50%
CI Test specs, both shards added up 4m52s 2m44s −44%
Wait for the CI workflow 6m30s 6m56s no change

Local numbers are the mean of two runs each, at 7e25002. CI before is the median of 27 green PR runs since #1383 reduced CI to two shards. CI after is the median of this PR's three runs. The CI wait stays the same, because Build-Info waits for Build-And-Test and finishes last in 26 of 27 runs.

Changes

  • Splits the specs Vitest project into specs-dom for .tsx specs and specs-node for .ts specs.
  • Runs a .ts spec in jsdom only when it declares // @vitest-environment jsdom. CONTRIBUTING.md asks for the comment on the first line.
  • Uses the threads pool for the spec projects.
  • Removes the server.deps.inline list from vite.config.mts.
  • Loads @testing-library/jest-dom in test-setup.ts only when document exists.
  • Applies the Buffer instanceof Uint8Array patch in test-setup.ts to Uint8Array only, not to its subclasses.
  • Merges duplicate spec files into it.each tables.
  • Deletes spec files that copy a surviving spec.
  • Checks the size in triggerDownload before the base64 check, so an oversized payload fails before the scan.
  • Imports date-fns functions from subpaths.
  • Extracts formatAnchorIdl and formatCodamaIdl from their hooks.

Type of change

  • Other (please describe): test suite speed

Screenshots

No UI change.

Testing

  • Every spec runs in one project. Run pnpm exec vitest list --filesOnly --project specs-dom, then the same with --project specs-node. Expect each spec file outside packages/ in exactly one list.
  • Suite time. Run pnpm test:ci:specs on master and on this branch. Expect about half the wall time on this branch.

Related Issues

Closes HOO-1913

Checklist

  • My code follows the project's style guidelines
  • I have added tests that prove my fix/feature works
  • All checks pass locally (pnpm test, pnpm lint, pnpm typecheck)
  • I have updated documentation as needed
  • I have run build:info script to update build information

@vercel

vercel Bot commented Oct 6, 2026

Copy link
Copy Markdown

@askov is attempting to deploy a commit to the Solana Foundation Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps

greptile-apps Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable defect was found.

Summary

Splits specs between Node and jsdom, uses worker threads, and reduces repeated setup and test code.

  • Vitest runs DOM specs in jsdom and plain TypeScript specs in Node.
  • Anchor and Codama IDL formatting can run outside React hooks.
  • Date helpers import only the date-fns functions they use.
  • Downloads check the size limit before validating the base64 data.

Reviews (6) · Last reviewed commit: "chore(vitest): rename hoo-611 fixture an..." · Reviewed by Greptile

Comment thread scripts/feature-gates/lib/__tests__/module-graph.spec.ts Outdated
@askov
askov force-pushed the chore/vitest-environments branch from 314d7f6 to ae00b36 Compare October 6, 2026 09:24
@vercel

vercel Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
explorer Ready Ready Preview Oct 15, 2026 6:38am UTC

Request Review

@askov askov changed the title chore(vitest): run .ts specs in node and merge duplicate specs perf(vitest): halve spec suite time with node specs and worker threads Oct 6, 2026
Comment thread app/features/transaction-history/api/__tests__/get-signatures-for-address.spec.ts Outdated
@askov
askov force-pushed the chore/vitest-environments branch from ae00b36 to 9eec314 Compare October 12, 2026 13:05
Comment thread app/utils/date.ts
askov added 3 commits October 15, 2026 13:14
Every spec file created a jsdom window, which costs about half a second
per file. A `.ts` spec runs in node unless it declares
`// @vitest-environment jsdom`, and specs run in worker threads.
The spec suite takes 37 s instead of 75 s.
Node 22.1 to 22.6 read `--eval` input as CommonJS, so top-level await
throws before the pipeline imports run.

This branch was successfully deployed

1 active deployment
Preview — 6b2dc625 Deployed Oct 15, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants